package com.sci99.ex.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DptNode {
	private DptNode parent;
	private List<DptNode> children;
	private Long index;
	private int dep;
	private String label = "";

	public DptNode() {

	}

	public DptNode(Department dep) {
		this.index = dep.getId();
		this.label = dep.getBumen();
		this.dep = dep.getDep();
	}

	public void setParent(DptNode parent) {
		this.parent = parent;
	}

	public DptNode getParent() {
		return this.parent;
	}

	public void appendChild(DptNode child) {
		if (children == null)
			children = new ArrayList<>();
		children.add(child);
	}

	public List<DptNode> getChildren() {
		if (children == null)
			return Collections.emptyList();
		return children;
	}

	public void setIndex(Long index) {
		this.index = index;
	}

	public Long getIndex() {
		return index;
	}

	public String getLabel() {
		return this.label;
	}

	public int getDep() {
		return dep;
	}

	public void setDep(int dep) {
		this.dep = dep;
	}

	public String toString() {
		return getLabel();
	}
}
